package com.bilifuture.service;

import com.bilifuture.statemachine.enums.StateMachineEvent;
import com.bilifuture.statemachine.enums.StateMachineType;
import com.bilifuture.statemachine.machine.StateMachine;
import com.bilifuture.statemachine.message.Message;
import com.bilifuture.statemachine.message.Response;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author bilifuture
 * @description:
 * @date 2022-04-02
 */
@Slf4j
@Component
public class OrderService {
    
    @Autowired
    private StateMachine stateMachine;
    
    public void submitOrder(){
        Response response = stateMachine.trigger(StateMachineType.Order, StateMachineEvent.SUBMIT, Message.builder().build());
        log.info("OrderService 状态机执行结果 response:{}",response);
    }
}
